/* For legacy reading systems */
article,
aside,
figure,
figcaption,
footer,
header,
main,
nav,
section{
	display: block;
}

/* ADE can't handle the way we hide the title/author/contributor blocks in the titlepage, so hide them from ADE... */
section[epub|type~="titlepage"] h1,
section[epub|type~="titlepage"] p,
section[epub|type~="colophon"] h2,
section[epub|type~="imprint"] h2{
	display: none;
}

/* ...but enable them for accessibility in all other ereaders */
@supports(font-size: 0){
	section[epub|type~="titlepage"] h1,
	section[epub|type~="titlepage"] p,
	section[epub|type~="colophon"] h2,
	section[epub|type~="imprint"] h2{
		display: block;
	}
}

/* Epub2 compatibility CSS */
img[epub|type~="z3998:publisher-logo"]{
	width: 222px; /* This gets scaled up by 2px when adding the white outside path during the build process */
}

/* Give PNGs a white background for night mode compatibility... */
img[epub|type~="se:image.color-depth.black-on-transparent"]{
	background: #fff !important; /* `!important` is required to make sure readers respect the BG color */
}

/* ...except our house PNGs, which were rendered from SVGs with a white stroke... */
[epub|type~="titlepage"] img[epub|type~="se:image.color-depth.black-on-transparent"],
img[epub|type~="se:image.color-depth.black-on-transparent"][epub|type~="z3998:publisher-logo"]{
	background: transparent !important;
}

/* ...or if the device supports prefers-color-scheme. We’ll invert the image in core.css. RMSDK requires a target media as well as a state. */
@media all and (prefers-color-scheme){
	img[epub|type~="se:image.color-depth.black-on-transparent"]:not([epub|type~="se:image.style.realistic"]){
		background: transparent !important;
	}
}

/* Vertical align any MathML images we might have */
img.mathml{
	vertical-align: middle;
}

/* As of 2020-09 hanging punctuation only works on iBooks. However, when it hangs over the page margin, it's
   not rendered. So here we simply remove it for iBooks, unless it's on an element that already has a margin
   like <blockquote> */
:root[__ibooks_internal_theme] blockquote + p,
:root[__ibooks_internal_theme] h2 + p,
:root[__ibooks_internal_theme] h3 + p,
:root[__ibooks_internal_theme] h4 + p,
:root[__ibooks_internal_theme] h5 + p,
:root[__ibooks_internal_theme] h6 + p,
:root[__ibooks_internal_theme] header + p,
:root[__ibooks_internal_theme] hr + p,
:root[__ibooks_internal_theme] ol + p,
:root[__ibooks_internal_theme] ul + p,
:root[__ibooks_internal_theme] table + p,
:root[__ibooks_internal_theme] hgroup + p,
:root[__ibooks_internal_theme] p:first-child{
	hanging-punctuation: none !important;
}

:root[__ibooks_internal_theme] blockquote p:first-child{
	hanging-punctuation: first last !important;
}

/* Apple Books will load a pannable zoomable table view when clicked, which is useful unless you’re
   trying to read a piece of drama. */
:root[__ibooks_internal_theme] [epub|type~="z3998:drama"] table,
:root[__ibooks_internal_theme] table[epub|type~="z3998:drama"]{
	pointer-events: none;
}

:root[__ibooks_internal_theme] [epub|type~="z3998:drama"] table a,
:root[__ibooks_internal_theme] table[epub|type~="z3998:drama"] a{
	pointer-events: auto;
}
